package guoanmaker.personal.business.dao;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.transaction.Transactional;

import org.springframework.stereotype.Repository;

import guoanmaker.personal.business.model.PersonalAppraise;
/**
 * 
* @ClassName: PersonalAppraiseDao 
* @Description: 查询评价dao
* @author Yvonne_MGL
* @date 2017年7月20日 下午4:02:00 
*  
 */
@Repository
public class PersonalAppraiseDao {
	@PersistenceContext
	EntityManager em;
	
	/**
	 * 
	* @Description: 根据订单id查询评价 
	* @param orderid 订单id
	* @param @return
	* @author Yvonne_MGL 
	* @date 2017年7月20日 下午4:06:02     
	* @return List<PersonalAppraise>    
	* @throws 
	 */
	public List<PersonalAppraise> findByOrderId(String orderid){
		String jpql="select a from PersonalAppraise a left join a.orderForm o where o.id='"+orderid+"'";
		Query query = em.createQuery(jpql);
		List<PersonalAppraise> list=query.getResultList();
		return list;
	}
//	@Transactional
//	public List<PersonalAppraise> insertReplyById(String orderid,String reply){
//		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
//		Date date = new Date();
//		
//		String jpql="update PersonalAppraise p set p.reply='" + reply + "' and p.appraiseTime='" + sdf.format(date) + "' where p.id='" + orderid +"'";
//		em.e
//		return null;
//	}
}
